import module from './Module.js'
//工具模块
export default module.define('Util', [], function (c) {
  return {
    total(data, field) {
      return data.reduce((sum, goods) => sum + goods[field], 0)
    },
    order(data, field, type = 'asc') {
      return data.sort((a, b) => {
        return type == 'asc' ? a[field] - b[field] : b[field] - a[field]
      })
    },
  }
})
